package com.teamwork.ZuccEcho.Entity;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

////老师
//@Entity
//@Table(name = "Teacher", schema = "", catalog = "")
//public class Teacher {
//    private String tchId;//工号(唯一)
//    private String tPwd;//密码，初始888888
//    private String tName;//姓名
//    private List<Questionnaire> questionnaires;//所有反馈
//    private List<Info> tInfo;//所有系统通知
//    private List<Class> classes;//教学班
//
//    @Id
//    @Column(name = "tchId")
//    @GeneratedValue(strategy = GenerationType.AUTO)
//    public String getTchId() {
//        return tchId;
//    }
//
//    public void setTchId(String tchId) {
//        this.tchId = tchId;
//    }
//
//    @Basic
//    @Column(name = "tPwd")
//    public String gettPwd() {
//        return tPwd;
//    }
//
//    public void settPwd(String tPwd) {
//        this.tPwd = tPwd;
//    }
//
//    @Basic
//    @Column(name = "tName")
//    public String gettName() {
//        return tName;
//    }
//
//    public void settName(String tName) {
//        this.tName = tName;
//    }
//
//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Teacher that = (Teacher) o;
//        return tchId == that.tchId &&
//                Objects.equals(tPwd, that.tPwd) &&
//                Objects.equals(tName, that.tName);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(tchId, tPwd, tName);
//    }
//}

//老师
@Entity
//@Data
@Getter
@Setter
public class Teacher {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String tch_id;//工号(唯一)
    private String tch_pwd;//密码，初始888888
    private String tch_name;//姓名

//    @OneToMany()
    @OneToMany(mappedBy = "teacher")
//    @JoinColumn(name="tch_id")//在子表中的外键名
    private List<Model> modelList;

//    @OneToMany()
    @OneToMany(mappedBy = "teacher")
//    @JoinColumn(name="tch_id")//在子表中的外键名
    private List<Course> courseList;

////    @OneToMany()
//    @OneToMany(mappedBy = "teacher")
////    @JoinColumn(name="tch_id")//在子表中的外键名
//    private List<Info> infoList;

    @Override
    public String toString() {
        return "Teacher{" +
                "tch_id='" + tch_id + '\'' +
                ", tch_pwd='" + tch_pwd + '\'' +
                ", tch_name='" + tch_name + '\'' +
                '}';
    }
}
//**若用了@Data，再用toString方法，会Teacher和Course两个类反复输出信息，导致栈溢出。